"""
    接口层：实现代理商端二级代理商账号、技术支持、终端客户的创建
"""
import requests
import random


# 创建代理商端账号新建类
class ApiCreateSecAgent(object):

    # 新建二级代理商账号
    def api_create_secagent(self, url, token, *args):
        headers = {"Content-Type": "application/json", "Authorization": token}
        data = {
            "account": "Secagent" + str(random.randint(2000, 9999)),
            "addrDetail": "详细地址",
            "countryCode": "1070000",
            "countryName": "关岛",
            "email": str(random.randint(1000, 9999)) + "341@qq.com",
            "name": "二级代理姓名" + str(random.randint(50, 9999)),
            "password": "PEpmBuX8p/GaIggqzgZVEw==",
            "phone": [
                "0775-666688889999"
            ],
            "province": {
                "area": "",
                "city": "",
                "province": ""
            },
            "provinceLabel": "",
            "roleId": 2001,
            "userId": "76274c5ea988427883180a2438ca74a5"
        }
        return requests.post(url, headers=headers, json=data)

    # 新建技术支持账号
    def api_create_tecsupport(self, url, token, *args):
        headers = {"Content-Type": "application/json", "Authorization": token}
        data = {
            "account": "tecsupport" + str(random.randint(2000, 9999)),
            "addrDetail": "详细地址",
            "countryCode": "1070000",
            "countryName": "关岛",
            "email": str(random.randint(1000, 9999)) + "134@qq.com",
            "name": "技术支持姓名" + str(random.randint(50, 9999)),
            "password": "PEpmBuX8p/GaIggqzgZVEw==",
            "phone": [
                "0771-123456789"
            ],
            "province": {
                "area": "",
                "city": "",
                "province": ""
            },
            "provinceLabel": "",
            "roleId": 1002,
            "userId": "76274c5ea988427883180a2438ca74a5"
        }
        return requests.post(url, headers=headers, json=data)

    # 新建终端客户账号
    def api_create_customer(self, url, token, *args):
        headers = {"Content-Type": "application/json", "Authorization": token}
        data = {
            "account": "customer" + str(random.randint(2000, 9999)),
            "addrDetail": "详细地址",
            "countryCode": "1070000",
            "countryName": "关岛",
            "email": str(random.randint(1000, 9999)) + "456@qq.com",
            "name": "终端客户姓名" + str(random.randint(50, 9999)),
            "password": "PEpmBuX8p/GaIggqzgZVEw==",
            "phone": [
                "0665-7894563210"
            ],
            "province": {
                "area": "",
                "city": "",
                "province": ""
            },
            "provinceLabel": "",
            "roleId": 1003,
            "userId": "76274c5ea988427883180a2438ca74a5"
        }
        return requests.post(url, headers=headers, json=data)
